package com.ficus.road.maintain.core.model.zh;

import com.ficus.road.maintain.core.model.RoadTypeEnum;
import lombok.Data;
import org.springframework.util.StringUtils;

/**
 * @author xiawen yang
 * @date 2022/8/20 下午2:30
 */
@Data
public class UnitScoreDetailZH {
    private Double deductScore;

    private String unid;

    private Integer seqNo;

    private Double proportion;

    private String punid;

    private String filePath;

    private String createdate;

    private String scoreStandard;

    private String sections;

    private String firstProject;

    private String twoProject;

    private String deductScoreReason;

    private Double fullMarks;

    private Double getScore;

    public UnitScoreDetail convert2UnitScoreDetail(UnitScoreDetailZH zh, String date) {
        return UnitScoreDetail.builder()
                .id(zh.getUnid())
                .pid(zh.getPunid())
                .seqNo(zh.getSeqNo())
                .proportion(zh.getProportion())
                .filePath(zh.getFilePath())
                .createDate(zh.getCreatedate())
                .scoreStandard(zh.getScoreStandard())
                .unitId(zh.getSections())
                .firstProject(zh.getFirstProject())
                .secondProject(zh.getTwoProject())
                .fullMarks(zh.getFullMarks())
                .score(zh.getGetScore())
                .deductScore(zh.getDeductScore())
                .deductScoreReason(zh.getDeductScoreReason())
                .date(date)
                .type(convertType(zh.getSections()))
                .build();
    }

    private String convertType(String unitId) {
        if (StringUtils.isEmpty(unitId) || unitId.contains("YHGL")) {
            return RoadTypeEnum.HIGHWAY.toString();
        } else {
            return RoadTypeEnum.ROAD.toString();
        }
    }
}
